home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Entertainment / luff stuff / luff⁄autom.c < prev    next >
Encoding:
Text File  |  1985-11-08  |  1.5 KB  |  60 lines  |  [TEXT/MACA]

  1. # include "def.h"
  2.  
  3. /* Scans the tabel who defines the finite automat */
  4.  
  5. autom(){
  6.     register int state, i, way;
  7.     short int who, j;
  8.     unsigned char *atm;
  9.     char (*p)[17], (*t)[17];
  10.     unsigned char *newpts;
  11.     char *oldpts;
  12.     unsigned char *newtht;
  13.     char *oldtht;
  14.     char max;
  15.  
  16.     for(way = 0; way < 4; way++){
  17.         state = 0;
  18.         atm = automat[0];
  19.         p = tmppts[way];
  20.         t = tmptht[way];
  21.         for(i = 0; i < 17; i++){
  22.             p[0][i] = 0;
  23.             p[1][i] = 0;
  24.             t[0][i] = 0;
  25.             t[1][i] = 0;
  26.         }
  27.         for(i = 0; i < 17; i++){
  28.             switch(hvlr[way][i]){
  29.                 case ' ':
  30.                     state = atm[0];
  31.                     break;
  32.                 case 'o':
  33.                     state = atm[1];
  34.                     who = 0;
  35.                     break;
  36.                 case 'x':
  37.                     state = atm[2];
  38.                     who = 1;
  39.                     break;
  40.                 default:
  41.                     state = 0;
  42.             }
  43.             atm = automat[state];
  44.             if(atm[3]){
  45.                 max = 3 * atm[3] + 4;
  46.                 for(j = 4; j < max; j += 3){
  47.                     oldpts = &p[who][i - atm[j]];
  48.                     newpts = &atm[j + 2];
  49.                     oldtht = &t[who][i - atm[j]];
  50.                     newtht = &atm[j + 1];
  51.                     if(*newtht > *oldtht)
  52.                         *oldtht = *newtht;
  53.                     if(*newpts > *oldpts)
  54.                         *oldpts = *newpts;
  55.                 }
  56.             }
  57.         }
  58.     }
  59. }
  60.